<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');?>
<p>Новый заказ на сайте №<?=$order['order_id']?>.</p>
<table cellspacing='1' cellpadding='5' border='1'><tbody>
	<tr>
		<th>Имя</th>
		<td><?=$userdata['name_1']?> <?=$userdata['name_2']?> <?=$userdata['name_3']?></td>
	</tr>
	<tr>
		<th>Телефон</th>
		<td><?=$userdata['phone']?></td>
	</tr>
	<tr>
		<th>Эл. почта</th>
		<td><?=$userdata['email']?></td>
	</tr>
	<tr>
		<th>Адрес доставки</th>
		<td><?=$userdata['address_4']?>, <?=$userdata['address_1']?>, <?=$userdata['address_2']?>, <?=$userdata['address_3']?></td>
	</tr>
	<tr>
		<th>Комментарий</th>
		<td><?=$order['order_comment']?></td>
	</tr>
	<tr>
		<th>Способ оплаты</th>
		<td><?
		if ($order['order_payment'] == "prepaid") {
			echo "ПРЕДОПЛАТА: ";
			switch ($order['order_prepaid_payment']) {
				case "sber": echo "СберБанк"; break;
				case "alfa": echo "АльфаБанк"; break;
				case "qiwi": echo "Qiwi"; break;
			}
		} else {
			echo "НАЛОЖЕННЫЙ ПЛАТЕЖ";
		}
		?></td>
	</tr>
</tbody></table>
<h3>Товары</h3>
<?
	$basket = json_decode($order['order_data'], true);
	if (sizeof($basket) > 0) {
		?>
		<table cellspacing='1' cellpadding='5' border='1'><tbody>
			<tr>
				<th>#</th>
				<th>Название</th>
				<th>Количество</th>
				<th>Цена</th>
				<th>Сумма</th>
			</tr>
		<?
		$i = 0;

		foreach ($basket as $key => $item) {
			$i++;
			echo "<tr>";
				echo "<td>";
					echo $i;
				echo "</td>";
				echo "<td>";
					echo $item['name'];
				echo "</td>";
				echo "<td style='text-align: center; width: 60px;'>";
					echo $item['count'];
				echo "</td>";
				echo "<td>";
					echo tonum(($order['order_payment'] == "prepaid"?$item['price2']:$item['price']));
				echo "</td>";
				echo "<td>";
					echo tonum(($order['order_payment'] == "prepaid"?$item['sum2']:$item['sum']));
				echo "</td>";
			echo "</tr>";

		}
		?>
		</tbody></table>
		<?
		echo "<p style='font-size: 18px;'>Общая сумма: ".tonum(($order['order_payment'] == "prepaid"?$order['order_sum2']:$order['order_sum']))." рублей</p>";
	}
echo "<p>Спасибо за заказ!</p>";
echo "<p>Это письмо сформировано автоматически, отвечать на него не нужно.</p>";